package oms.controllers;

import oms.entities.Item;
import oms.entities.Order;
import oms.entities.User;
import oms.service.ItemService;
import oms.service.OrderService;
import oms.service.UserService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;


@Controller
@RequestMapping(value = "/search")
public class SearchController {

		//@Autowired	
		private UserService userService;
		
		//@Autowired
		private OrderService orderService;
		
		//@Autowired
		private ItemService itemService;
		
		
		@RequestMapping(value = "/users/{userId}", method = RequestMethod.GET)
	    @ResponseBody
	    public User getById(@PathVariable Long userId) {
			
				return userService.getUserById(userId);
	    }
		
		@RequestMapping(value = "/orders/{orderId}", method = RequestMethod.GET)
	    @ResponseBody
	    public Order getOrderById(@PathVariable Long orderId) {
			
				return orderService.getOrderById(orderId);
	    }
		
		@RequestMapping("items/{name}")
		@ResponseBody
		public Item getItemByName(@PathVariable String name) {
			
				return itemService.getItemByName(name);
		}
		
		@RequestMapping("items/{description}")
		@ResponseBody
		public Item getItemByDescription(@PathVariable String description) {
			
				return itemService.getItemByName(description);
		}
		
		
		
		
		
}
